package com.baseweb.webadmin.core.constants;

import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.List;

public enum AuthLevel {
    GERENCHUJI(1, "个人初级认证"), GERENZHONGJI(2, "个人中级认证"), GERENGAOJI(3, "个人高级认证"),
    GERENZONGJIAN(4, "个人总监认证"), GERENDASHI(5, "个人大师认证"), GERENHUANGGUAN(6, "个人皇冠认证"), GERENJIGUAN(7, "个人金冠认证"),
    YIXINBAIYING(8, "一星白银团队"), ERXINGHUANGJIN(9, "二星黄金团队"), SANXINGBAIJIN(10, "三星白金团队"),
    SIXINGZHUANSHI(11, "四星钻石团队"), WUXINGDASHI(12, "五星大师团队"), LIUXINGHUANGGUAN(13, "六星皇冠团队"), QIXINGZHIZUN(14, "七星至尊团队");

    private int code;
    private String name;

    AuthLevel(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static List<AuthLevel> getAllData() {
        List<AuthLevel> result = new ArrayList<AuthLevel>();
        for (AuthLevel current : AuthLevel.values()) {
            result.add(current);
        }
        return result;
    }

    public static List<AuthLevel> getUnAuthData(String authListStr) {
        List<AuthLevel> result = new ArrayList<AuthLevel>();

        for (AuthLevel current : AuthLevel.values()) {
            if (StringUtils.isBlank(authListStr) || authListStr.indexOf("" + current.getCode()) == -1) {
                result.add(current);
            }
        }
        return result;
    }

    public static AuthLevel getNameByCode(int code) {
        List<AuthLevel> allData = getAllData();
        for (AuthLevel status : allData) {
            if (status.getCode() == code) {
                return status;
            }
        }
        return null;
    }

    public static List<String> getPersonTypeOpt() {
        List<String> list = new ArrayList<>();
        for (AuthLevel current : AuthLevel.values()) {
            if(current.getCode()>7) break;
            String string = current.getCode() + ";" + current.getName();
            list.add(string);
        }
        return list;
    }
    public static List<String> getTeamTypeOpt() {
        List<String> list = new ArrayList<>();
        for (AuthLevel current : AuthLevel.values()) {
            if(current.getCode()<=7) continue;
            String string = current.getCode() + ";" + current.getName();
            list.add(string);
        }
        return list;
    }
    public static void main(String[] args) {
        System.out.println(getPersonTypeOpt());
        System.out.println(getTeamTypeOpt());
    }
}
